package cn.com.capinfo.ea.example.demo.service



import cn.com.capinfo.ea.example.demo.domain.Author
import org.junit.Test
import org.junit.runner.RunWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.context.annotation.ComponentScan
import org.springframework.core.annotation.Order
import org.springframework.test.context.ActiveProfiles
import org.springframework.test.context.junit4.SpringRunner
/**
 * Generate by CapinfoTools EA-3.7.0 on 2020-07-27.
 */

@ComponentScan(basePackages=["cn.com.capinfo"])
@ActiveProfiles("test")
@RunWith(SpringRunner.class)
@SpringBootTest
@EnableAutoConfiguration
class AuthorServiceTests {
    @Autowired AuthorService authorService
    @Test
    public void testCRUD(){
        long count=authorService.count({})
        Author author = authorService.create([:])
         //@todo 完善属性赋值
        //author.name='xxx'
        authorService.save(author)
        assert authorService.count({})==(count+1)
        author=authorService.get(author.id)
         //@todo 修改属性值
        //author.name='xxx'
        authorService.save(author)
        //@todo 判断值是否修改
        //assert authorService.get(author.id).name='xxx'
        authorService.delete(author)
        assert authorService.count({})==count
    }
}
